
package com.wasion.gydpe.common.util;

import java.io.IOException;
import java.util.Properties;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
 
/**
 * <p>配置文件加载器</p>
 * 读取配置文件，如下所示：
 * <pre>
 * ConfigReader loader = new ConfigReader(
					"classpath:IceComm.config");
			reciever = loader.getProperty("ServiceClockCalibrator.Proxy");
 * </pre>
 * @author cyl
 *
 */
public class ConfigReader {


    private Properties config = new Properties();
	private ResourceLoader loader = new DefaultResourceLoader();  
	
	 
	/**
	 * @param rs spring 格式属性资源名称
	 * @throws ConfigurationException
	 * @throws IOException
	 */
	public ConfigReader(String rs) throws  IOException { 
		Resource resource = loader.getResource(rs);
		config.load(resource.getInputStream());
	}

	public String getProperty (String key)  {
		if (config.containsKey(key)) {
			return config.getProperty(key).toString();
		}
		return null;
	}
}
